package com.ybjzo2o.customer.handler;

import com.ybjzo2o.customer.model.domain.CurrentUser;
import com.ybjzo2o.customer.model.domain.TokenInfo;
import com.ybjzo2o.customer.utils.TokenUtils;

public class TokenHelper {
    public TokenHelper() {
    }

    public static String generateTokenOfUser(String appId, String accessKeyId, String accessKeySecret, CurrentUser currentUser) {
        TokenInfo tokenInfo = new TokenInfo();
        tokenInfo.setSignType("common");
        tokenInfo.setAppId(appId);
        tokenInfo.setCurrentUser(currentUser);
        return TokenUtils.generateToken(tokenInfo, 3600000L, accessKeyId, accessKeySecret);
    }

    public static String generateTokenOfAdmin(String appId, String accessKeyId, String accessKeySecret, CurrentUser currentUser) {
        TokenInfo tokenInfo = new TokenInfo();
        tokenInfo.setSignType("admin");
        tokenInfo.setAppId(appId);
        tokenInfo.setCurrentUser(currentUser);
        return TokenUtils.generateToken(tokenInfo, 3600000L, accessKeyId, accessKeySecret);
    }
}